package metadata_tab

import (
	"fmt"

	"file_explorer/view/packed_widgets"
	"file_explorer/view/store"
)

type StatusBar struct {
	*packed_widgets.Label

	tabCtx *store.MetadataTabContext
}

func (bar *StatusBar) refreshStatus() {
	text := fmt.Sprintf("%d项", len(bar.tabCtx.FileInfos))
	if len(bar.tabCtx.CheckFiles) > 0 {
		text += fmt.Sprintf(", %d项被选中", len(bar.tabCtx.CheckFiles))
	}
	bar.SetText(text)
}

func NewStatusBar(tabCtx *store.MetadataTabContext) *StatusBar {
	return &StatusBar{
		Label:  packed_widgets.NewLabel(""),
		tabCtx: tabCtx,
	}
}
